package kubernetes

import (
	"k8s-admin/models"

	appsv1 "k8s.io/api/apps/v1"
	corev1 "k8s.io/api/core/v1"
	v1 "k8s.io/api/core/v1"
)

type InterfaceK8s interface {
	AddK8sCluster(cluster *models.Configs) (err error)
	ListK8sCluster(Limit, Page int) (*models.ClusterK8sList, error)
	DeleteK8sCluster(cid []string) error
	GetK8sClusterNodeList(cid, name string, page, limit int) (nodeResp []map[string]interface{}, err error)
	GetK8sClusterNodeDetail(cid string, name string) (node *corev1.Node, err error)
	GetClusterNamespaceLists(cid string) (*NamespaceList, error)
	CreateClusterNamespace(cid, NamespaceName string) error
	DeleteClusterNamespace(cid, NamespaceName string) error
	GetK8sClusterPod(cid, namespace string) (*PodesResp, error)
	GetK8sClusterNamePod(cid, namespace, PodName string) (*corev1.Pod, error)
	//GetK8sClusterPodYaml(cid, namespace, PodName string) (string, error)
	DeleteK8sClusterPod(cid, namespace, PodName string) error
	GetK8sClusterPodContainer(cid, namespace, PodName string) ([]map[string]interface{}, error)
	GetK8sClusterPodLogs(cid, namespace, PodName, ContainerName string) (string, error)
	GetClusterServiceList(cid, namespace string) (*ServicesList, error)
	GetClusterServiceInfo(cid, namespace, serviceName string) (*corev1.Service, error)
	GetClusterDeploymentList(cid, Namespace string) (*DeploymentList, error)
	CreateClusterDeploymentUI(cid, Namespace string, DeploymentData string) error
	GetClusterDeployment(cid, Namespace, DeploymentName string) (*appsv1.Deployment, error)
	CreateClusterDeployment(cid, Namespace string, DeploymentData string) error
	CreateClusterDeploymentFile(cid, Namespace string, DeploymentData string) error
	DeleteClusterDeployment(cid, Namespace, DeploymentName string) error
	UpdateClusterDeployment(cid, Namespace, DeploymentData string) error
	CreateClusterService(cid, Namespace, name, protocol, port, targetPort, ServiceType, nodePort string) error
	CreateClusterServiceYaml(cid, Namespace string, YamlData string) error
	UpdateClusterService(cid, Namespace, YamlData string) error
	DeleteK8sClusterService(cid, namespace, ServiceName string) error
	CreateClusterStatefulSetYaml(cid, Namespace string, StatefulSetData string) error
	UpdateClusterStatefulSet(cid, Namespace, StatefulSetData string) error

	GetClusterStatefulSetList(cid, Namespace string) (*StatefulSet, error)
	GetClusterStatefulSet(cid, Namespace, StatefulSetName string) (*appsv1.StatefulSet, error)
	DeleteClusterStatefulSet(cid, Namespace, StatefulSetName string) error
	CreteClusterConfigMap(cid, Namespace, ConfigMapData string) error
	GetClusterConfigMapList(cid, Namespace string) (*ConfigMapList, error)
	GetClusterConfigMapInfo(cid, Namespace, ConfigMapName string) (*v1.ConfigMap, error)
	DeleteClusterConfigMap(cid, Namespace, ConfigMapName string) error
	UpdateClusterConfigMap(cid, Namespace, ConfigMapYaml string) error
	CreteClusterSecret(cid, Namespace, SecretData string) error
	GetClusterSecretList(cid, Namespace string) (*SecretList, error)
	GetClusterSecretInfo(cid, Namespace, SecretName string) (*v1.Secret, error)
	DeleteClusterSecret(cid, Namespace, SecretName string) error
	UpdateClusterSecret(cid, Namespace, SecretYaml string) error
	// CreteClusterDaemon 通过yaml方式创建daemonSet资源
	CreteClusterDaemonSet(cid, Namespace, DaemonData string) error
	GetClusterDaemonSetList(cid, Namespace string) (*DaemonList, error)
	GetClusterDaemonSetInfo(cid, Namespace, DaemonName string) (*appsv1.DaemonSet, error)
	DeleteClusterDaemonSet(cid, Namespace, DaemonName string) error
	UpdateClusterDaemonSet(cid, Namespace, DaemonYaml string) error
}

type k8sCluster struct{}

func NewK8sInterface() InterfaceK8s {
	return &k8sCluster{}
}
